package test.pdfToText;

import java.io.File;
import java.io.IOException;

/**
 * 类描述：   
 * 创建人：jinyongliang
 * 创建时间：2012-1-10 下午01:14:19   
 * 修改人：jinyongliang   
 * 修改时间：2012-1-10 下午01:14:19   
 * 修改备注：   
 * @version 
 */
public class ConvertPdf
{
	private static String INPUT_PATH;
	private static String PROJECT_PATH;
	
	public static void convertToHtml(String file, String project)
	{
		INPUT_PATH = file;
		PROJECT_PATH = project;
		if(checkContentType()==0)
		{
			toHtml();
		}
	}
	
	private static int checkContentType()
	{
		String type = INPUT_PATH.substring(INPUT_PATH.lastIndexOf(".") + 1, INPUT_PATH.length())
				.toLowerCase();
		if (type.equals("pdf"))
			return 0;
		else
			return 9;
	}
	
	private static void toHtml()
	{
		if(new File(INPUT_PATH).isFile())
		{
			try
			{
				String cmd = "cmd /c start D:\\software\\xpdf\\pdftohtml.bat \"" + PROJECT_PATH + "\" \"" + INPUT_PATH + "\"";
				Runtime.getRuntime().exec(cmd);
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}
	}
	
	public static void main(String[] args)
	{
		ConvertPdf.convertToHtml("e:\\pdf\\600660_2011_3.pdf", "D:\\software\\xpdf\\xpdfbin-win-3.03\\xpdfbin-win-3.03\\bin32");
	}
	
}
